<% layout('/layouts/default.html', {title: '任务部署信息表(主)管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-tools pull-left" style="position: relative">
				<ul class="nav nav-tabs bangPing-tabs">
					<li ><a href="${ctx}/taskdeploy/dcSupTaskInfoSecretary/list">${text('待提交')}</a></li>
					<li class="active"><a href="${ctx}/taskdeploy/dcSupTaskInfoSecretary/listed">${text('已提交')}</a></li>
				</ul>
			</div>
			<#form:form id="searchForm" model="${dcSupTaskInfo}" action="${ctx}/taskdeploy/dcSupTaskInfoSecretary/queryListData?taskStatus=2&normalFlag=2" method="post" class="form-inline"
			data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div style="float: right">

				<div class="form-group">
					<label class="control-label">${text('任务年度')}：</label>
					<div class="control-inline width-120">
						<#form:select path="taskYear" items="${yearList}" blankOption="true" data-placeholder="请选择" itemLabel="yearLabel" itemValue="yearValue" class="form-control width-120" defaultValue="${currentYear}"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务标题')}：</label>
					<div class="control-inline width-160">
						<#form:input path="taskTitle" maxlength="200" class="form-control width-160" placeholder="请输入任务标题"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务类型')}：</label>
					<div class="control-inline width-160">
						<#form:select path="taskTypeCode" items="${dicts}" blankOption="true" data-placeholder="请选择" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-160"/>
					</div>
				</div>
				<div class="form-group">
					<!--					<label class="control-label">${text('数据过滤')}：</label>-->
					<div class="control-inline width-90">

						<% if(hasRole('other_office')){ %>
						<% var items = [{label:'我的',value:'0'}]; %>
						<#form:select path="dataLimit" items="${items}" itemLabel="label" itemValue="value" defaultValue="0" class="form-control required" />
						<% } else{ %>
						<% var items = [{label:'我的',value:'0'},{label:'本科室',value:'2'},{label:'本单位',value:'1'}]; %>
						<#form:select path="dataLimit" items="${items}" itemLabel="label" itemValue="value" defaultValue="0" class="form-control required" />
						<% } %>

					</div>
				</div>
				<div class="form-group" >
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</div>
		</#form:form>
	</div>
	<div class="box-body">
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
	</div>
</div>
</div>
<% } %>
<script>
	//重置
	$(function () {
		if('${dcSupTaskInfo.remarks3}'){
			$("#dataGrid").jqGrid('GridUnload');
			$("#pageNo").val('${dcSupTaskInfo.remarks3}');
			$("#pageSize").val('${dcSupTaskInfo.remarks4}');
			$('#dataGrid').dataGrid({
				searchForm: $("#searchForm"),
				sortableColumn: false, // 列表不允许排序
				columnModel: [
					{header:'${text("主键")}', name:'id', index:'a.id', width:150, align:"left", hidden:true},
					{header:'${text("督办字号")}', name:'messageNumber', index:'a.message_number', width:100, align:"left"},
					{header:'${text("任务标题")}', name:'taskTitle', index:'a.task_title', width:150, align:"left"
						, formatter: function(val, obj, row, act){
							var pageNo = $("#pageNo").val();
							var pageSize = $("#pageSize").val();
							var messageNumber =encodeURIComponent(row.messageNumber);
							var taskTitle =encodeURIComponent(row.taskTitle);
							return '<a href="${ctx}/taskdeploy/dcSupTaskInfoSecretary/messageNumberListed?messageNumber='+messageNumber+'&taskYear='+row.taskYear+'&taskTitle='+taskTitle+'&taskTypeCode='+row.taskTypeCode+'&remarks3='+pageNo+'&remarks4='+pageSize+'" class="btnList" data-title="${text("同标题任务查看")}">'+(val||'暂无标题')+'</a>';
						}
					},
					{header:'${text("任务类型")}', name:'taskTypeName', index:'a.task_type_name', width:150, align:"left"},
				],
				page: '${dcSupTaskInfo.remarks3}',	// 当前页码
				rowNum: '${dcSupTaskInfo.remarks4}',
				// 加载成功后执行事件
				ajaxSuccess: function(data){

				}
			});
		}
	})

	function cz(){
		searchForm.reset();
		$('#dataGrid').dataGrid('reloadGrid');
	}

	// 初始化DataGrid对象
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		sortableColumn: false, // 列表不允许排序
		columnModel: [
			{header:'${text("主键")}', name:'id', index:'a.id', width:150, align:"left", hidden:true},
			{header:'${text("督办字号")}', name:'messageNumber', index:'a.message_number', width:100, align:"left"},
			{header:'${text("任务标题")}', name:'taskTitle', index:'a.task_title', width:150, align:"left"
				, formatter: function(val, obj, row, act){
					var pageNo = $("#pageNo").val();
					var pageSize = $("#pageSize").val();
					var messageNumber =encodeURIComponent(row.messageNumber);
					var taskTitle =encodeURIComponent(row.taskTitle);
					return '<a href="${ctx}/taskdeploy/dcSupTaskInfoSecretary/messageNumberListed?messageNumber='+messageNumber+'&taskYear='+row.taskYear+'&taskTitle='+taskTitle+'&taskTypeCode='+row.taskTypeCode+ '&searchType=accurated&remarks4='+pageSize+'" class="btnList" data-title="${text("同标题任务查看")}">'+(val||'暂无标题')+'</a>';
				}
			},
			{header:'${text("任务类型")}', name:'taskTypeName', index:'a.task_type_name', width:150, align:"left"},
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});

	function showSubTask(id) {
		js.addTabPage(null, "子任务明细","${ctx}/action/dcSupTaskAction/listOrg?taskId="+id , true);
	}

	function editTask(id) {
		js.addTabPage(null, "编辑督办任务","${ctx}/taskdeploy/dcSupTaskInfo/form?id="+id , true);
	}

	function arrangeHis(id) {
		js.addTabPage(null, "整理历史","${ctx}/arrange/dcSupTaskInfoArrange?taskId="+id , true);
	}
	function arrangeTask(taskId){
		js.layer.open({
			type: 2,
			title: ['整理任务'],
			area: ['1000px', '460px'],
			scrollbar: true,
			shadeClose: false,
			content: "${ctx}/taskdeploy/dcSupTaskInfo/arrangeTask?taskId="+taskId,
			btn1: function (index, layero) {
			},
			end:function () {
				$('#dataGrid').dataGrid('refresh', 1, 20);
			}
		});
	}
</script>